package cn.tedu.csmall.product.webapi.controller;

import cn.tedu.csmall.commons.response.JsonResult;
import cn.tedu.csmall.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmall.pojo.vo.AlbumAddNewVO;
import cn.tedu.csmall.product.service.IAlbumService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/albums")
@Api(tags = "4.相册管理模块")
public class AlbumController {

    @Autowired
    private IAlbumService service;

    /**
     * 新增相册
     * @param albumAddNewDTO 封装的新增相册属性
     * @return 相册的Json字符串
     */
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "增加相册")
    @PostMapping("/add-new")
    public JsonResult<AlbumAddNewVO> addNew(@Valid AlbumAddNewDTO albumAddNewDTO){
        Long id = service.addNew(albumAddNewDTO);
        AlbumAddNewVO albumAddNewVO = new AlbumAddNewVO();
        albumAddNewVO.setId(id);
        return JsonResult.ok(albumAddNewVO);
    }

}
